import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

/**
 * @author CoderXshuai
 * @date 2021/8/7 20:10
 */
public class TreeTraversalsAgain {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Stack<String> stack = new Stack<>();
        StringBuilder builder = new StringBuilder();
        int n = Integer.parseInt(reader.readLine());
        String s;
        stack.push("");
        for (int i = 0; i < 2 * n; i++) {
            s = reader.readLine();
            if ("Pop".equals(s)) {
                while ("Pop".equals(stack.peek())) {
                    stack.pop();
                    builder.append(stack.pop().split(" ")[1]).append(" ");
                }
            }
            stack.push(s);
        }
        while (stack.size() > 1) {
            s = stack.pop();
            if (!"Pop".equals(s))
                builder.append(s.split(" ")[1]).append(" ");
        }
        System.out.println(builder.deleteCharAt(builder.length() - 1));
        reader.close();
    }
}
